package com.cn.yugan.Widget.NestedView.RecycleView;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;

import java.util.List;
/**
 * Created by Rover on 2016/8/18 .
 * Email 357319517@qq.com
 */


public abstract class MultiItemCommonAdapter<T> extends CommonAdapter<T> {
    protected MultiItemTypeSupport<T> mMultiItemTypeSupport;

    public MultiItemCommonAdapter(Context context, List<T> datas, MultiItemTypeSupport<T> multiItemTypeSupport) {
        super(context, -1, datas);
        this.mMultiItemTypeSupport = multiItemTypeSupport;
    }

    public int getItemViewType(int position) {
        return this.mMultiItemTypeSupport.getItemViewType(position, this.mDatas.get(position));
    }

    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        int layoutId = this.mMultiItemTypeSupport.getLayoutId(viewType);
        ViewHolder holder = ViewHolder.get(this.mContext, (View)null, parent, layoutId, -1);
        this.setListener(parent, holder, viewType);
        return holder;
    }
}
